home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PAS_0493 / SYNC.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-15  |  2KB  |  60 lines

  1. {─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
  2. Msg  : 114 of 150
  3. From : Sean Palmer                         1:104/123.0          08 Apr 93  15:35
  4. To   : All
  5. Subj : G:Sync Unit
  6. ────────────────────────────────────────────────────────────────────────────────}
  7. { Sync unit  v1.0 }
  8. {   04/06/93      }
  9. { Minimal support for cpu-independent timing, Turbo Pascal 6.0}
  10. { Copyright (c) 1993 Sean L. Palmer }
  11. { Released to the Public Domain }
  12.  
  13. { You may distribute this freely and incorporate it with no royalties. }
  14. { Please credit me if your program uses these routines! }
  15. { If you really like them or learn something neat from me then I'd }
  16. { appreciate a small ($1 to $5) donation. }
  17. { Or contact me if you need something programmed or like my work... }
  18. { I probably have the wierdest indenting style for pascal ever! 8)  }
  19. { And, by God my stuff is optimized!! }
  20.  
  21. { Sean L. Palmer (aka Ghost)}
  22. { 2237 Lincoln St. }
  23. { Longmont, CO 80501 }
  24. { (303) 651-7862 }
  25. { also on FIDO, or at palmers@spot.colorado.edu }
  26.  
  27. unit sync;
  28. {$A-,B-,D-,E-,F-,G-,I-,L-,N-,O-,R-,S-,V-,X-}
  29. interface
  30. var ticks:word absolute $40:$6C;   {ticks happen 18.2 times/second}
  31.  
  32. procedure tick;                             {pauses until next tick}
  33. function ticked:boolean;    {true if tick occurred since last check}
  34. procedure waitTicks(n:word);  {pauses for specified number of ticks} 
  35.  
  36. implementation
  37.  
  38. var curTick:word;
  39.  
  40. procedure tick;begin curTick:=succ(ticks);repeat until ticks=curTick;end;
  41.  
  42. function ticked:boolean;begin
  43.  if curTick<>ticks then begin curTick:=ticks; ticked:=true; end
  44.  else ticked:=false;
  45.  end;
  46.  
  47. procedure waitTicks(n:word);begin
  48.  curTick:=ticks+n;  {will wrap}
  49.  repeat until ticks=curTick;
  50.  end;
  51.  
  52. begin
  53.  curTick:=ticks;
  54.  end.
  55. ___ Blue Wave/QWK v2.12
  56.  
  57. --- Maximus 2.01wb
  58.  * Origin: >>> Sun Mountain BBS <<< (303)-665-6922 (1:104/123)
  59.  
  60.